package com.newbe.controller;

import com.newbe.entity.User;
import com.newbe.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Optional;

/**
 * @Auther: Newbe
 * @Date: 2019/9/24 23:58
 * @Description:
 */
@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("/findUserById")
    public Optional<User> getUserById(int id){
        return userService.getUserById(id);
    }

    @RequestMapping("/findAll")
    public List<User> findUserAll(){
        return userService.getUserAll();
    }

    @RequestMapping("/del")
    public void del(int id){
        userService.del(id);
    }

    @RequestMapping("/save")
    public User save(User user){
        return userService.save(user);
    }

}
